'use strict';

module.exports = {
  up: (queryInterface, Sequelize) => {
    const { INTEGER, STRING, DATE, ENUM, TEXT } = Sequelize;
    return queryInterface.createTable("user", {
      id: {
        type: INTEGER(20),
        primaryKey: true,
        autoIncrement: true,
      },
      number: {
        type: STRING(30),
        allowNull: true,
        defaultValue: '',
        comment: '学号',
        unique: true
      },
      username: {
        type: STRING(30),
        allowNull: false,
        defaultValue: "",
        comment: "用户名",
        unique: true,
      },
      password: {
        type: STRING,
        allowNull: false,
        defaultValue: "",
        comment: "密码",
      },
      openid: {
        type: STRING,
        allowNull: false,
        defaultValue: "",
        comment: "openid",
      },
      gender: {
        type: INTEGER,
        allowNull: false,
        defaultValue: 1,
        comment: "性别"
      },
      class_id: {
        type: INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: "班级id"
      },
      phoneNumber: {
        type: INTEGER,
        allowNull: true,
        defaultValue: "",
        comment: "手机号",
      },
      birthday: {
        type: STRING,
        allowNull: true,
        defaultValue: "",
        comment: "生日",
      },
      avatar: {
        type: STRING,
        allowNull: true,
        defaultValue: "",
        comment: "头像",
      },
      coin: {
        type: INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: "金币",
      },
      created_time: DATE,
      updated_time: DATE,
    });
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.dropTable("user");
  },
};